#include <stdio.h>
#include <string.h>

//#define STDIN
//#define DEBUG

#define MAX_N 202

int T, N;
int arrray[MAX_N][2];
int c[MAX_N];

void compute()
{
	int i, j;

#ifdef DEBUG
	for (i = 0; i < N; ++i)
	{
			printf("%d %d\t", arrray[i][0], arrray[i][1]);
	printf("\n");
	}
#endif
	memset(c, 0, sizeof(c));

	for (i = 0; i < N; ++i)
	{
		for (j = (arrray[i][0]+1)/2; j <= (arrray[i][1]+1)/2; j++) 
			c[j]++;
	}
#ifdef DEBUG
	for (i = 1; i < 100; ++i)
		printf("%d ", c[i]);
	printf("\n");
#endif

	int min = 0;
	for (i = 1; i < MAX_N; ++i)
		if (min < c[i])
			min = c[i];
	printf("%d\n", min * 10);
}

int main()
{
#ifdef STDIN
	freopen("bin/1083.in", "r", stdin);
#endif

	int i, j;
	scanf("%d", &T);
	for (i = 0; i < T; i += 1)
	{
		scanf("%d", &N);
		for (j = 0; j < N; j += 1)
		{
			scanf("%d %d", &arrray[j][0], &arrray[j][1]);
			if (arrray[j][0] > arrray[j][1])
			{
				int tmp = arrray[j][1];
				arrray[j][1] = arrray[j][0];
				arrray[j][0] = tmp;
			}

		}
		compute();
	}
	return 0;
}
